clear
clear matrix
clear mata
program drop _all
set more off
set emptycells drop
set maxvar 100000
tempfile main
cap log close
log using Table14 actual,replace

cd "<directory>"

*The code in this .do file reads in the dataset created in Data Cleaning Step 2.do and runs the regressions for Table 14;
*Before the estimation commands are run, the quarter of the rule change is dropped;
*The "_m" suffixes in the outreg commands stipulate which DPO window the model corresponds to:;
*	_m1 = DPO[-4,-7];
*	_m2 = DPO[-5,-8];
*	_m3 = DPO[-6,-9];
*	_m4 = DPO[-7,-10];

/*********************************************************************************
*Note: The following block of code appears before every regression. This code identifies and drops observations that Stata will automatically drop in the course of the probit estimation. This code is optional and all the regressions can be run without it. However, using this code speeds up the estimation significantly, because Stata does not have to determine whether to drop these obervations as it goes through the estimation;
*	tempfile msayq
*	keep if !missing(transfer, post, dspp0_5t8, post_dspp0_5t8, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
*	keep if dcountss_2==1
*	keep if yearmonth>=572 & yearmonth<=620
*	collapse (mean) transfer,by(msayq)
*	gen indic=1 if transfer==0
*	keep msayq indic
*	sa `msayq',replace
*	u `main',clear
*	merge m:1 msayq using `msayq'
*	drop if _merge==2
*	drop _merge
***********************************************************************************/


u final_dataset,clear
drop if distyq==198
sa `main',replace


u `main',clear
tempfile msayq
assert transfer==. if transfer_fullpay2==.
assert transfer_fullpay2==. if transfer==.
keep if !missing(transfer, post, dspp0_5t8, post_dspp0_5t8, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_fullpay2 post dspp0_5t8 post_dspp0_5t8,by(msayq)
gen indic=1 if transfer_fullpay2==0
keep msayq indic
sa `msayq',replace
u `main',clear
merge m:1 msayq using `msayq'
drop if _merge==2
drop _merge


probit transfer_fullpay2 dspp0_5t8 post_dspp0_5t8 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssid i.origyq i.msayq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelA_m2, auto(2) excel replace stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)




u `main',clear
tempfile ssmsa
keep if !missing(transfer, post, dspp0_5t8, post_dspp0_5t8, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, origyq, ssmsa, distyq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_fullpay2 post dspp0_5t8 post_dspp0_5t8,by(ssmsa)
gen indic=1 if transfer_fullpay2==0
keep ssmsa indic
sa `ssmsa',replace
u `main',clear
merge m:1 ssmsa using `ssmsa'
drop if _merge==2
drop _merge


probit transfer_fullpay2  dspp0_5t8 post_dspp0_5t8 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssmsa i.origyq i.distyq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelA_m2, auto(2) excel append stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)




u `main',clear
tempfile msayq
keep if !missing(transfer, post, dspp0_4t7, post_dspp0_4t7, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_fullpay2 post dspp0_5t8 post_dspp0_5t8,by(msayq)
gen indic=1 if transfer_fullpay2==0
keep msayq indic
sa `msayq',replace
u `main',clear
merge m:1 msayq using `msayq'
drop if _merge==2
drop _merge


probit transfer_fullpay2  dspp0_4t7 post_dspp0_4t7 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssid i.origyq i.msayq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelA_m1, auto(2) excel replace stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)




u `main',clear
tempfile ssmsa
keep if !missing(transfer, post, dspp0_4t7, post_dspp0_4t7, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, origyq, ssmsa, distyq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_fullpay2 post dspp0_4t7 post_dspp0_4t7,by(ssmsa)
gen indic=1 if transfer_fullpay2==0
keep ssmsa indic
sa `ssmsa',replace
u `main',clear
merge m:1 ssmsa using `ssmsa'
drop if _merge==2
drop _merge


probit transfer_fullpay2  dspp0_4t7 post_dspp0_4t7 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssmsa i.origyq i.distyq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelA_m1, auto(2) excel append stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)




u `main',clear
tempfile msayq
keep if !missing(transfer, post, dspp0_6t9, post_dspp0_6t9, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_fullpay2 post dspp0_6t9 post_dspp0_6t9,by(msayq)
gen indic=1 if transfer_fullpay2==0
keep msayq indic
sa `msayq',replace
u `main',clear
merge m:1 msayq using `msayq'
drop if _merge==2
drop _merge



probit transfer_fullpay2  dspp0_6t9 post_dspp0_6t9 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssid i.origyq i.msayq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelA_m3, auto(2) excel replace stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)





u `main',clear
tempfile ssmsa
keep if !missing(transfer, post, dspp0_6t9, post_dspp0_6t9, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, origyq, ssmsa, distyq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_fullpay2 post dspp0_6t9 post_dspp0_6t9,by(ssmsa)
gen indic=1 if transfer_fullpay2==0
keep ssmsa indic
sa `ssmsa',replace
u `main',clear
merge m:1 ssmsa using `ssmsa'
drop if _merge==2
drop _merge


probit transfer_fullpay2  dspp0_6t9 post_dspp0_6t9 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssmsa i.origyq i.distyq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelA_m3, auto(2) excel append stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)







u `main',clear
tempfile msayq
keep if !missing(transfer, post, dspp0_7t10, post_dspp0_7t10, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_fullpay2 post dspp0_7t10 post_dspp0_7t10,by(msayq)
gen indic=1 if transfer_fullpay2==0
keep msayq indic
sa `msayq',replace
u `main',clear
merge m:1 msayq using `msayq'
drop if _merge==2
drop _merge


probit transfer_fullpay2  dspp0_7t10 post_dspp0_7t10 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssid i.origyq i.msayq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelA_m4, auto(2) excel replace stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)



u `main',clear
tempfile ssmsa
keep if !missing(transfer, post, dspp0_7t10, post_dspp0_7t10, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, origyq, ssmsa, distyq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_fullpay2 post dspp0_7t10 post_dspp0_7t10,by(ssmsa)
gen indic=1 if transfer_fullpay2==0
keep ssmsa indic
sa `ssmsa',replace
u `main',clear
merge m:1 ssmsa using `ssmsa'
drop if _merge==2
drop _merge


probit transfer_fullpay2  dspp0_7t10 post_dspp0_7t10 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssmsa i.origyq i.distyq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelA_m4, auto(2) excel append stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)




u `main',clear
tempfile msayq
assert transfer==. if transfer_nodlq2==.
assert transfer_nodlq2==. if transfer==.
keep if !missing(transfer, post, dspp0_5t8, post_dspp0_5t8, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_nodlq2 post dspp0_5t8 post_dspp0_5t8,by(msayq)
gen indic=1 if transfer_nodlq2==0
keep msayq indic
sa `msayq',replace
u `main',clear
merge m:1 msayq using `msayq'
drop if _merge==2
drop _merge


probit transfer_nodlq2 dspp0_5t8 post_dspp0_5t8 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssid i.origyq i.msayq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelB_m2, auto(2) excel replace stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)






u `main',clear
tempfile ssmsa
keep if !missing(transfer, post, dspp0_5t8, post_dspp0_5t8, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, origyq, ssmsa, distyq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_nodlq2 post dspp0_5t8 post_dspp0_5t8,by(ssmsa)
gen indic=1 if transfer_nodlq2==0
keep ssmsa indic
sa `ssmsa',replace
u `main',clear
merge m:1 ssmsa using `ssmsa'
drop if _merge==2
drop _merge


probit transfer_nodlq2  dspp0_5t8 post_dspp0_5t8 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssmsa i.origyq i.distyq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelB_m2, auto(2) excel append stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)




u `main',clear
tempfile msayq
keep if !missing(transfer, post, dspp0_4t7, post_dspp0_4t7, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_nodlq2 post dspp0_5t8 post_dspp0_5t8,by(msayq)
gen indic=1 if transfer_nodlq2==0
keep msayq indic
sa `msayq',replace
u `main',clear
merge m:1 msayq using `msayq'
drop if _merge==2
drop _merge


probit transfer_nodlq2  dspp0_4t7 post_dspp0_4t7 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssid i.origyq i.msayq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelB_m1, auto(2) excel replace stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)





u `main',clear
tempfile ssmsa
keep if !missing(transfer, post, dspp0_4t7, post_dspp0_4t7, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, origyq, ssmsa, distyq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_nodlq2 post dspp0_4t7 post_dspp0_4t7,by(ssmsa)
gen indic=1 if transfer_nodlq2==0
keep ssmsa indic
sa `ssmsa',replace
u `main',clear
merge m:1 ssmsa using `ssmsa'
drop if _merge==2
drop _merge



probit transfer_nodlq2  dspp0_4t7 post_dspp0_4t7 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssmsa i.origyq i.distyq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelB_m1, auto(2) excel append stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)





u `main',clear
tempfile msayq
keep if !missing(transfer, post, dspp0_6t9, post_dspp0_6t9, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_nodlq2 post dspp0_6t9 post_dspp0_6t9,by(msayq)
gen indic=1 if transfer_nodlq2==0
keep msayq indic
sa `msayq',replace
u `main',clear
merge m:1 msayq using `msayq'
drop if _merge==2
drop _merge


probit transfer_nodlq2  dspp0_6t9 post_dspp0_6t9 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssid i.origyq i.msayq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelB_m3, auto(2) excel replace stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)






u `main',clear
tempfile ssmsa
keep if !missing(transfer, post, dspp0_6t9, post_dspp0_6t9, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, origyq, ssmsa, distyq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_nodlq2 post dspp0_6t9 post_dspp0_6t9,by(ssmsa)
gen indic=1 if transfer_nodlq2==0
keep ssmsa indic
sa `ssmsa',replace
u `main',clear
merge m:1 ssmsa using `ssmsa'
drop if _merge==2
drop _merge


probit transfer_nodlq2  dspp0_6t9 post_dspp0_6t9 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssmsa i.origyq i.distyq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelB_m3, auto(2) excel append stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)




u `main',clear
tempfile msayq
keep if !missing(transfer, post, dspp0_7t10, post_dspp0_7t10, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, ssid, origyq, msayq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_nodlq2 post dspp0_7t10 post_dspp0_7t10,by(msayq)
gen indic=1 if transfer_nodlq2==0
keep msayq indic
sa `msayq',replace
u `main',clear
merge m:1 msayq using `msayq'
drop if _merge==2
drop _merge


probit transfer_nodlq2  dspp0_7t10 post_dspp0_7t10 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssid i.origyq i.msayq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelB_m4, auto(2) excel replace stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)






u `main',clear
tempfile ssmsa
keep if !missing(transfer, post, dspp0_7t10, post_dspp0_7t10, orig_ltv, securwac, securocc, orig_dscrnoi2, age, balratio, ltv, occrate, dscrnoi, propid, dealtypeid, originatorid, origyq, ssmsa, distyq)
keep if dcountss_2==1
keep if yearmonth>=572 & yearmonth<=620
collapse (mean) transfer_nodlq2 post dspp0_7t10 post_dspp0_7t10,by(ssmsa)
gen indic=1 if transfer_nodlq2==0
keep ssmsa indic
sa `ssmsa',replace
u `main',clear
merge m:1 ssmsa using `ssmsa'
drop if _merge==2
drop _merge


probit transfer_nodlq2  dspp0_7t10 post_dspp0_7t10 remterm orig_ltv securwac securocc orig_dscrnoi2 age balratio ltv occrate dscrnoi i.propid i.dealtypeid i.originatorid i.ssmsa i.origyq i.distyq if yearmonth>=572 & yearmonth<=620 & nouse2==0 & dcountss_2==1 & indic!=1,cluster(masterloanidtrepp)
outreg2 using Table14PanelB_m4, auto(2) excel append stats(coef se) addstat(Pseudo R2, e(r2_p)) addtext(Orig Year-Q FE, Y, Curr Year-Q FE, N, SS FE, Y, PropType FE, Y, DealType FE, Y, Originator FE, Y, MSA-Year-Q FE, Y, MSA-SS FE, N, SE Clust by loan, Y, Estimation, Probit)